<script type="text/javascript">
	jQuery(document).ready(function() {

		$.ajaxPrefilter(function(options, originalOptions, jqXHR) {

			var oldErrorHandler = options.error;
			
			options.error = function(jqXHR, textStatus, error) {
		        
		        if (error === "Unauthorized") {
		        	window.location.href = "${createLink(controller: 'index', action:'login')}"
		        }
		        
		        if (oldErrorHandler)
		        	oldErrorHandler();
		    };
		});
	});
</script>